/**
 * 将样式配置，结果维度数据映射关系，数据转换为echart的options
 * @param style
 * @param relativeConfig
 * @param data
 */
function template(title,style,relativeConfig,data){

    let fieldConfig = {legend:'',data:[]};

    for(let index in relativeConfig){

        let relationItem = relativeConfig[index];

        if(relationItem.relationDimension == 'legend' ){

            fieldConfig.legend = relationItem.resultColumn;
        }else if(relationItem.relationDimension == 'data' ){
            fieldConfig.data.push(relationItem.resultColumn);
        }
    }




    let legendKey = fieldConfig.legend['columnField'];

    let legendDesc = fieldConfig.legend['columnDesc'];

    let dataKeys = fieldConfig.data;


    let series=[];

    for(let index in dataKeys){

        series.push({
            name:legendDesc,
            field:dataKeys[index]['columnField'],
            name:dataKeys[index]['columnDesc'],
            type:'pie',
            data:[]
        });
    }

    let legendData =[];

    for(let index in data){

        legendData.push(data[index][legendKey]);
    }

    for( let index in data){

        let dataitem = data[index];

        for(let sindex in series){

            let serie = series[sindex];

            serie.data.push({
                name:dataitem[legendKey],
                value:dataitem[serie.field]});
        }

    }


    let option = {
        title : {
            text: title,
            x:'center'
        },
        tooltip : {
            trigger: 'item',
            formatter: "{a} <br/>{b} : {c} ({d}%)"
        },
        legend: {
            type: 'scroll',
            orient: 'vertical',
            right: 10,
            top: 20,
            bottom: 20,
            data: legendData,

        },
        series :series
    };

    return option;

}